package com.jackyzgy.test.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class Client {
	
	public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException {
		Socket client = new Socket("localhost", 30000);
		ObjectInputStream objectInputStream = new ObjectInputStream(client.getInputStream());
		List list = (List) objectInputStream.readObject();
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
		
//		BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
//	    String requestStr = reader.readLine();
//	    
//	    JSONArray array = JSONArray.fromObject(requestStr);
//		for (int i = 0; i < array.size(); i++) {
//			JSONObject jsonObject = JSONObject.fromObject(array.get(i));
//			System.out.println(jsonObject.getString("content"));
//		}
	    
//		PrintStream printStream = new PrintStream(client.getOutputStream());
//		printStream.println(">>>>>>>>>>>>>>>>> happy new year too ");
//		printStream.flush();
//		printStream.close();
		objectInputStream.close();
//		reader.close();
//		client.close();
	}

}
